/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once
#include "ScanMethod.h"

class ScanMethodIgmp : public ScanMethod
{
protected:
	virtual int InternalInit(void);
	virtual int InternalExecute(void);

	virtual void ComputeRandomValues(void);

	in_addr dstIpAddress;
	in_addr grpIpAddress;
	BYTE queryVersion;
	bool SendIgmpQuery(ScanPacket*);

	virtual void ProcessIgmp(BYTE*, int, BYTE*);

public:
	ScanMethodIgmp(void);
	~ScanMethodIgmp(void);
};

/*
	V1:
	Message destinations: 
		Queries are addressed to the all-hosts group (address 224.0.0.1), and carry an IP time-to-live of 1
		No host will respond with their default membership (224.0.0.1)

	V2:
		Message destinations, TTL = 1
			Message Type                  Destination Group
			------------                  -----------------
			General Query                 ALL-SYSTEMS (224.0.0.1)
			Group-Specific Query          The group being queried
			Membership Report             The group being reported
			Leave Message                 ALL-ROUTERS (224.0.0.2)
		General query : like V1
		Specific query : group address specified

	V3:
		Message destionations: like V2. *However*, a system MUST accept and  process any Query whose IP Destination
			Address field contains *any* of the addresses (unicast or multicast) assigned to the interface on which the Query arrives.
		General query: like V1. "NumberOfSources"=0
		Specific query: group address specified. "NumberOfSources"=0
*/